﻿

using CommunityToolkit.Mvvm.ComponentModel;
using LiveCharts;
using LiveCharts.Defaults;

namespace Company.Shell.Models
{
    public class ProgramEntity : ObservableObject
    {

        public ProgramEntity()
        {
            Step = MaxXAxis / 12;
        }
        public string? Guid { get; set; }
        private string name = string.Empty;
        /// <summary>
        /// 程序名称
        /// </summary>
        public string Name
        {
            get => name;
            set => SetProperty(ref name, value);
        }

        private ChartValues<ObservablePoint> temperatures = [];
        /// <summary>
        /// 温度曲线坐标集合
        /// </summary>
        public ChartValues<ObservablePoint> Temperature
        {
            get => temperatures;
            set => SetProperty(ref temperatures, value);
        }

        private ChartValues<ObservablePoint> humidities = [];
        /// <summary>
        /// 湿度曲线坐标集合
        /// </summary>
        public ChartValues<ObservablePoint> Humidities
        {
            get => humidities;
            set => SetProperty(ref humidities, value);
        }

        private double maxXAxis = 1440;
        /// <summary>
        /// X轴最大值（分钟）
        /// </summary>
        public double MaxXAxis
        {
            get => maxXAxis;
            set => SetProperty(ref maxXAxis, value);
        }

        private double step = 120;
        /// <summary>
        /// X轴最大刻度值（分钟）
        /// </summary>
        public double Step
        {
            get => step;
            set => SetProperty(ref step, value);
        }
        /// <summary>
        /// 以天为单位增加X轴最大值
        /// </summary>
        /// <returns></returns>
        public double IncreaseXAxis()
        {
            MaxXAxis += 1440;
            if (MaxXAxis > 1440 * 7)
            {
               MaxXAxis = 1440 * 7;
            }
            Step = MaxXAxis / 12;
            return Step;
        }
        /// <summary>
        /// 以天为单位减少X轴最大值
        /// </summary>
        /// <returns></returns>
        public double DecreaseXAxis()
        {
            MaxXAxis -= 1440;
            if (MaxXAxis < 1440)
            {
                MaxXAxis = 1440;
            }
            Step = MaxXAxis / 12;
            return Step;
        }

    }
}
